package com.xiaotu.spider.guduo.pipeline;

import java.util.List;


import com.xiaotu.common.model.GuDuoNetMoviePlayCountModel;
import com.xiaotu.common.model.GuDuoSetsPlayCountModel;
import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.spider.APipeline;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;

/**
 * @功能 骨朵剧播放量
 */

public abstract class GuDuoSetsPlayCountPipeline extends APipeline
{
    @SuppressWarnings("unchecked")
	@Override
    protected void doProcess(ResultItems resultItems, Task task)
    {
    	List<GuDuoSetsPlayCountModel> list = (List<GuDuoSetsPlayCountModel>)resultItems.get(GuDuoSetsPlayCountModel.class.getName());
        if (list == null || list.size() == 0)
            return;
        String key = getRedisKey();
    	for(GuDuoSetsPlayCountModel m : list){
    		cacheHandler.hSet(key, m.getDataId()+"_第"+m.getSets()+"集_"+m.getResourceSiteId()+"_"+m.getId(), m);
    	}
        cacheHandler.setCacheTimeout(key);
    }

    public abstract String getRedisKey();
    
}
